<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title> 信息填写</title>
    <link rel="stylesheet" href="/assets/Public/css/style1.css"/>
    <script language="JavaScript" type="text/javascript" src="/assets/Public/js/jquery.min.1.11.3.js"></script>
    <style type="text/css">
        .textarea{
            margin: 10px 0px;
        }
    </style>
</head>
<body>


<!--<div id="con"></div>-->
<div id="bot">
<div id="box">
    <form action="/personage/waybill" method="post" onsubmit="return check();">
        <input type="hidden" name="users_id" value="<?php echo ($_SESSION['users']['id']); ?>"/>

        <div class=" way">
            <h3>物流信息</h3>
            <table width="100%" >
                <tr>
                    <td>物流渠道/Company：</td>
                    <td>
                        <select name="channel_id" id="comp" required=""  oninvalid="setCustomValidity('请选择渠道');" oninput="setCustomValidity('');">
                            <option value="">请选择</option>
                            <?php if(is_array($channel)): foreach($channel as $key=>$val): if($val['id']==$arr['qid']): ?><option value="<?php echo ($val['id']); ?>" selected><?php echo ($val['company']); ?></option>
                                <?php else: ?>
                                    <option value="<?php echo ($val['id']); ?>"><?php echo ($val['company']); ?></option><?php endif; endforeach; endif; ?>
                        </select>
                        <span>*</span>
                    </td>
                </tr>
                <tr>
                    <td>包裹件数/Parcel number：</td>
                    <td><input required="" type="number" name="piece_num" value="" oninvalid="setCustomValidity('请输入包裹件数');" oninput="setCustomValidity('');"/><span>*</span></td>
                </tr>
                <tr>
                    <td>包裹重量/Weight：</td>
                    <td>
                        <input required="" type="number" step="0.01" name="weight" value="" placeholder="总重量：单位（KG）" oninvalid="setCustomValidity('请输入物品重量');" oninput="setCustomValidity('');"/><span>*</span>
                    </td>
                </tr>
                <!--<tr>
                    <td>物流运单号：</td>
                    <td><input required="" type="text" name="way" value="" oninvalid="setCustomValidity('请输入物流运单号');" oninput="setCustomValidity('');"/><span>*</span></td>
                </tr>-->
            </table>
            <div id="goods_way">
                <table style="border-bottom: solid 1px #a5a5a5;width: 100%; margin-bottom: 20px" >
                    <tr>
                        <td>商品中文描述/goods_cn：</td>
                        <td><input type="text" required="" name="g_cname[]"  oninvalid="setCustomValidity('请输入物品中文名');" oninput="setCustomValidity('');"/><span>*</span></td>
                    </tr>
                    <tr>
                        <td>商品英文描述/goods_en：</td>
                        <td><input type="text" required="" name="g_ename[]" value="" oninvalid="setCustomValidity('请输入物品英文名');" oninput="setCustomValidity('');"/><span>*</span></td>
                    </tr>
                    <tr>
                        <td>海关编码/HS Code：</td>
                        <td ><input type="text" required="" name="HS[]" value="" oninvalid="setCustomValidity('请输入海关编码');" oninput="setCustomValidity('');"/><span>*</span></td>
                    </tr>
                    <tr>
                        <td>物品数量/Items：</td>
                        <td>
                            <input required="" type="text" name="g_items[]" value="1" oninvalid="setCustomValidity('请输入物品商品中文名');" oninput="setCustomValidity('');"/><span>*</span>
                        </td>
                    </tr>
                    <tr>
                        <td>物品总价/Total Prices：</td>
                        <td>
                            <input required="" type="text" name="g_total_prices[]" value="" oninvalid="setCustomValidity('请输入物品总价');" oninput="setCustomValidity('');"/><span>*</span>
                        </td>
                    </tr>
                    <tr>
                        <td>体积/volume：</td>
                        <td>
                            <input type="text" name="volume[]" value=""/>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="add_goods" id="add_goods" style="margin-top: 20px">
                <img src="/assets/Public/images/jiahao.png" alt="添加商品信息"/>添加商品信息
            </div>
        </div>
        <div class=" way">
            <h3>收件人信息</h3>
            <div class="lead"><a href="javascript:void(0);" onclick="showalert('/personage/rec_ajax','收件人信息导入');" id="rec" >导入收件人信息</a></div>
            <input type="hidden" name="r_id" id="r_id" value=""/>
            <table >
                <tr>
                    <td>收件人/ContactName：</td>
                    <td><input  type="text" name="recipients" id="recipients" value="" required oninvalid="setCustomValidity('请输入收件人');" oninput="setCustomValidity('');"/><span>*</span></td>
                </tr>
                <tr>
                    <td>联系电话/Tel NO.：</td>
                    <td><input  type="text" name=" rec_tel" id="rec_tel" value="" required oninvalid="setCustomValidity('请输入收件人联系电话');" oninput="setCustomValidity('');"/><span>*</span></td>
                </tr>
                <tr>
                    <td>公司名称/Company：</td>
                    <td><input  type="text" name="rec_comp" id="rec_comp" value=""/></td>
                </tr>
                <tr>
                    <td>国家/Country：</td>
                    <td><select name="country_id" id="rec_state" required="required" oninvalid="setCustomValidity('请输入收件人国家');" oninput="setCustomValidity('');">
                        <option value="">请选择</option>
                        <?php if(is_array($state)): foreach($state as $key=>$value): if($value['id']==$arr['cid']): ?><option value="<?php echo ($value['id']); ?>" selected><?php echo ($value['ename']); ?>/<?php echo ($value['cname']); ?></option>
                                <?php else: ?>
                                <option value="<?php echo ($value['id']); ?>"><?php echo ($value['ename']); ?>/<?php echo ($value['cname']); ?></option><?php endif; endforeach; endif; ?>
                    </select>
                        <span>*</span>
                    </td>
                </tr>
                <tr>
                    <td>省州/province：</td>
                    <td>
                        <!--<select name="rec_province" id="rec_province" required="required" oninvalid="setCustomValidity('请输入收件人省份);" oninput="setCustomValidity('');">
                            <option value="">请选择</option>
                        </select>-->
                        <input type="text" name="rec_province" id="rec_province"  required="required" oninvalid="setCustomValidity('请输入收件人省份);" oninput="setCustomValidity('');"/>
                        <span>*</span>
                    </td>
                </tr>
                <tr>
                    <td>城市/City：</td>
                    <td>
                        <!--<select name="rec_city" id="rec_city" required="required" oninvalid="setCustomValidity('请输入收件人城市');" oninput="setCustomValidity('');">
                            <option value="">请选择</option>
                        </select>-->
                        <input type="text" name="rec_city" id="rec_city"  required="required" oninvalid="setCustomValidity('请输入收件人城市');" oninput="setCustomValidity('');"/>
                        <span>*</span>
                    </td>
                </tr>
                <tr>
                    <td>地址/Address：</td>
                    <td>
                        <textarea name="rec_add" id="rec_add" class="textarea"  cols="20" rows="2" required="" oninvalid="setCustomValidity('请输入收件人地址');" oninput="setCustomValidity('');"></textarea>
                        <span>*</span>
                    </td>
                </tr>
                <tr>
                    <td>邮编/Postal/ZipCode：</td>
                    <td><input required type="text" name="rec_postcode" value="" oninvalid="setCustomValidity('请输入收件人邮编');" oninput="setCustomValidity('');"/><span>*</span></td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="checkbox" name="srec"value="1"/>保存此收件人信息</td>
                </tr>
            </table>
        </div>
        <div class=" way">
            <h3>发件人信息</h3>
                <div class="lead"><a href="javascript:void(0);" onclick="showalert('/personage/sen_ajax','寄件人信息导入')";>导入寄件人信息</a></div>
            <input type="hidden" name="s_id" id="s_id" value=""/>
            <table>
                <tr>
                    <td>寄件人/ContactName：</td>
                    <td><input  type="text" name="sender" id="sender" value="" required oninvalid="setCustomValidity('请输入寄件人');" oninput="setCustomValidity('');"/><span>*</span></td>
                </tr>
                <tr>
                    <td>联系电话/Tel NO.：</td>
                    <td><input  type="text" name="sen_tel" id="sen_tel" value="" required oninvalid="setCustomValidity('请输入寄件人联系电话');" oninput="setCustomValidity('');"/><span>*</span></td>
                </tr>
                <tr>
                    <td>邮箱/Email：</td>
                    <td><input type="email" name="sen_email" id="sen_email" value=""  required oninvalid="setCustomValidity('请输入寄件人邮箱');" oninput="setCustomValidity('');"/><span>*</span></td>
                </tr>

                <td>地址/Address：</td>
                <td>
                    <textarea name="sen_add" id="sen_add"  class="textarea" cols="21" rows="2" required="" oninvalid="setCustomValidity('请输入寄件人地址');" oninput="setCustomValidity('');"></textarea>
                    <span>*</span>
                </td>
                <tr>
                    <td></td>
                    <td><input type="checkbox" name="ssen" value="1"/>保存此发件人信息</td>
                </tr>
            </table>
            <table>
                <tr>
                    <td>物流公司：</td>
                    <td><input type="text" name="log_comp" value="" required oninvalid="setCustomValidity('请输入物流公司');" oninput="setCustomValidity('');"/><span>*</span></td>
                </tr>
                <tr>
                    <td>物流运单号：</td>
                    <td><input type="text" name="log_no" value="" required oninvalid="setCustomValidity('请输入物流运单号');" oninput="setCustomValidity('');"/><span>*</span></td>
                </tr>
            </table>
        </div>

        <!--<div class="box_bot way" style="margin-top: 10px">
            &lt;!&ndash;<h3>Goods Descriptions货物的详细描述</h3>
            <div>
                <div class="lead"><b>物品<span>1</span></b> &nbsp;&nbsp;<a href="javascript:void(0);">导入物品信息</a></div>
                <table>
                    &lt;!&ndash;<tr>
                        <td >类型/Type：</td>
                        <td><input required="" type="radio" name="type" value="1" checked/>包裹No-Documents<input required="" type="radio" name="type" value="2"/>文件Documents <span>*</span></td>
                    </tr>&ndash;&gt;
                    <tr>
                        <td>海关编码/HS Code：</td>
                        <td ><input type="text" required="" name="HS" value="" oninvalid="setCustomValidity('请输入海关编码');" oninput="setCustomValidity('');"/><span>*</span></td>

                    </tr>
                    <tr>
                        <td>商品中文描述/goods_cn：</td>
                        <td><input type="text" required="" name="g_cname"  oninvalid="setCustomValidity('请输入物品中文名');" oninput="setCustomValidity('');"/><span>*</span></td>
                    </tr>
                    <tr>
                        <td>商品英文描述/goods_en：</td>
                        <td><input type="text" required="" name="g_ename" value="" oninvalid="setCustomValidity('请输入物品英文名');" oninput="setCustomValidity('');"/><span>*</span></td>
                    </tr>
                    <tr>
                        <td>物品数量/Items：</td>
                        <td>
                            <input required="" type="text" name="g_items" value="1" oninvalid="setCustomValidity('请输入物品商品中文名');" oninput="setCustomValidity('');"/><span>*</span>
                        </td>
                    </tr>
                    <tr>
                        <td>物品总价/Total Prices：</td>
                        <td>
                            <input required="" type="text" name="g_total_prices" value="" oninvalid="setCustomValidity('请输入物品总价');" oninput="setCustomValidity('');"/><span>*</span>
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td><input type="checkbox" name="sgoods" value="1"/>保存此物品信息</td>
                    </tr>
                </table>
            </div>
            <div class="add_goods">
                <img src="/assets/Public/images/jiahao.png" alt="添加商品信息"/>添加商品信息
            </div>&ndash;&gt;
            <table>
                <tr>
                    <td>托运备注/Remark：</td>
                    <td>
                        <textarea name="remark"  cols="80" rows="4" style=" width: 500px" placeholder="请注明是否包含这些物品：电池（纯电池、内置电池、配套电池）、电容、电子烟、纺织品、木箱、手机、移动电源、仿名牌……不要超过254字符（127汉字）"></textarea>
                    </td>
                </tr>
            </table>
        </div>-->
        <div class="bottn">
            <input type="submit" name="submit" class="button green" value="提交" class="btn"/>&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="reset" name="reset" class="button green" value="重写" class="btn"/>
        </div>

    </form>

</div>
</div>

<script type="text/javascript">
    //导入

    //商品信息克隆
    $("#add_goods").click(function(){
        $("#goods_way").append($("#goods_way table:first-child").clone());
    });

    $(document).ready(function() {
        function check() {
            if (!("#comp").val() == false) {
                $("#comp").focus();
                return false;
            }
        }
        $("#comp").change(function () {
            var pid = $(this).val();
            if (pid && $("#rec_state").val()) {
                $.getJSON("/waybill/way_ajax", {country_id:$("#comp").val(),channel_id:pid }, function (msg) {
                    if (msg == 1) {
                        alert("你所选的国家没有你要发的渠道，请联系客服！");
                    }
                })
            }
        })
        $("#rec_state").change(function () {
            var pid = $(this).val();
            if(pid && $("#comp").val()){
                $.getJSON("/waybill/way_ajax",{country_id:pid,channel_id:$("#comp").val()},function(msg){
                    if(msg==1){
                        alert("你所选的国家没有你要发的渠道，请联系客服！");
                    }
                })
            }
            if(pid==false){
                $("#rec_province option").remove(".prov_son");
                $("#rec_city option").remove(".city_son");
                return false;
            }else{
                $("#rec_province option").remove(".prov_son");
                $("#rec_city option").remove(".city_son");
                $.getJSON("/waybill/ajax_country", {pid: pid}, function (smg) {
                    for (var x in smg) {
                        $("<option class='prov_son' value='" + smg[x].id + "'>" + smg[x].cname + "&nbsp;" + smg[x].ename + "</option>").appendTo("#rec_province");
                    }
                })
            }
        })
        $("#rec_province").change(function () {
            var pid = $(this).val();
            if(pid==false){
                $("#rec_city option").remove(".city_son");
                return false;
            }else{
                $("#rec_city option").remove(".city_son");
                $.getJSON("/waybill/ajax_country", {pid: pid}, function (smg) {
                    for (var x in smg) {
                        $("<option class='city_son' value='" + smg[x].id + "'>" + smg[x].cname + "&nbsp;" + smg[x].ename + "</option>").appendTo("#rec_city");
                    }
                })
            }
        })

    })

</script>
<link rel="stylesheet" href="/assets/Public/css/theme1.css" media="all">
<script src="/assets/Public/js/jquery.min.js"></script>
<style>

</style>
<div class="theme-popover">
    <div class="theme-poptit">
        <a href="javascript:;" title="关闭" class="close">×</a>
        <h3 style="border: none"></h3>
    </div>
    <div class="theme-popbod dform" id="count">
        <table>
        </table>
        <div class="top_bot">
            <a href="javascript:;" title="确定" class="cla" id="cla">确定</a>
        </div>

    </div>

</div>
<div class="theme-popover-mask"></div>

<script>

    function showalert(url,data){
        $(".theme-poptit h3").text(data);
        var coun=''
        if(url=="/personage/rec_ajax"){
            $("#count table").empty();
            $("#cla").attr("urldata","/personage/rec_info");
            $.getJSON(url,{},function(msg){
                for( var x in msg){
                    coun+="<tr><td><input type=\"radio\" name='radio' value='"+msg[x].id+"'/>"+msg[x].recipients+"</td></tr>";
                }
                $("#count table").append(coun);
            })
        }else{
            $("#count table").empty();
            $("#cla").attr("urldata","/personage/sen_info");
            $.getJSON(url,{},function(msg){
                for( var x in msg){
                    coun+="<tr><td><input type=\"radio\" name='radio' value='"+msg[x].id+"'/>"+msg[x].sender+"</td></tr>";
                }
                $("#count table").append(coun);
            })
        }

        $('.theme-popover-mask').fadeIn(100);
        $('.theme-popover').slideDown(200);
    }
    $('.theme-poptit .close').click(function(){
        $('.theme-popover-mask').fadeOut(100);
        $('.theme-popover').slideUp(200);
    })
    //点击确认事件
    $('.top_bot .cla').click(function(){
        var val=$('input:radio[name="radio"]:checked').val();
        var url= $("#cla").attr("urldata");
        if(val!=null){
            $.getJSON(url,{id:val},function(msg){
                if(url=="/personage/sen_info"){
                    $("#s_id").val(msg[0].id);
                    $("#sender").val(msg[0].sender);
                    $("#sen_tel").val(msg[0].sen_tel);
                    $("#sen_email").val(msg[0].sen_email);
                    $("#sen_add").val(msg[0].sen_add);
                }else{
                    $("#r_id").val(msg[0].id);
                    $("#recipients").val(msg[0].recipients);
                    $("#rec_tel").val(msg[0].rec_tel);
                    $("#rec_comp").val(msg[0].rec_comp);
                    $("#rec_postcode").val(msg[0].rec_postcode);
                }
            })
        }
        $('.theme-popover-mask').fadeOut(100);
        $('.theme-popover').slideUp(200);
    })
</script>

</body>
</html>